Skip to content

[Terrain] Keep ADT liquid out of points buried under its terrain - #488

Open
ornfelt wants to merge 1 commit into
mangoszero:masterfrom
ornfelt:fix/adt-liquid-under-terrain
Open

ornfelt wants to merge 1 commit into
mangoszero:masterfrom
ornfelt:fix/adt-liquid-under-terrain

Conversation

@ornfelt

@ornfelt ornfelt commented Oct 29, 2026 •

Copy link
Copy Markdown

TerrainInfo::getLiquidStatus took the highest liquid in the column under a point and only checked it against the floor the point stands on. The ADT liquid goes into that column whatever its height, so in a city or a cave below the surface the tile's water counted as water the player stands in, however far above the ceiling it was.

In the Undercity Rogues' Quarter, at the rogue trainer (1418, 58, -62), the column holds Tirisfal's ADT water at 32.93 -- under its own terrain at 34.14 and about 95 yards above the floor. Every player there gets a breath timer and drowns once it runs out (60s, four times that for Undead).

The GridMap::getLiquidStatus this replaced judged ADT liquid against the ADT terrain at the point: no liquid when the level is below that terrain, or the point is more than 2 yards under it. Carry the terrain height with the ADT liquid (LiquidInfo / Surface terrainZ; none over a hole or for a model's liquid, as INVALID_HEIGHT made it before) and select with Column::LiquidFor(z), which skips an ADT liquid that does not reach the point. getLiquidStatus and mangos-height-check use it; GetTerrainType, which has no z, keeps HighestLiquid.

Verification

  • 359 tests pass, including five new cases in src/tests/TerrainModelTest.cpp (behind WITH_TESTS).
  • mangos-height-check --verbose on the baked tiles: the trainer's spots now report liquid=none (were water@32.93); the lake beside them (1307, 15) still reports water from its bed to its surface, as before.
  • Live with a 1.12.1 client: no breath bar at the rogue trainer; a breath bar in that lake.
  • Builds with 0 errors (GCC, Release, Linux); the touched files also pass a Clang syntax check. No added line over 80 columns, git diff --check clean.

This change is Reviewable

TerrainInfo::getLiquidStatus took the highest liquid in the column under a
point and only checked it against the floor the point stands on. The ADT
liquid goes into that column whatever its height, so in a city or a cave below
the surface the tile's water counted as water the player stands in, however
far above the ceiling it was.

In the Undercity Rogues' Quarter, at the rogue trainer (1418, 58, -62), the
column holds Tirisfal's ADT water at 32.93 -- under its own terrain at 34.14
and about 95 yards above the floor. Every player there gets a breath timer and
drowns once it runs out (60s, four times that for Undead).

The GridMap::getLiquidStatus this replaced judged ADT liquid against the ADT
terrain at the point: no liquid when the level is below that terrain, or the
point is more than 2 yards under it. Carry the terrain height with the ADT
liquid (LiquidInfo / Surface terrainZ; none over a hole or for a model's
liquid, as INVALID_HEIGHT made it before) and select with
Column::LiquidFor(z), which skips an ADT liquid that does not reach the point.
getLiquidStatus and mangos-height-check use it; GetTerrainType, which has no
z, keeps HighestLiquid.
Copilot AI balanced review requested due to automatic review settings October 29, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues for the height-aware liquid-selection change.

No open issues 🎉

What changed in this PR

This PR prevents ADT surface water from affecting players beneath its terrain, addressing unintended drowning in underground areas such as the Undercity Rogues’ Quarter.

Changes:

  • Carries ADT terrain height with liquid data and adds height-aware liquid selection.
  • Uses the new selector in gameplay liquid checks and height-check diagnostics, while preserving HighestLiquid for callers without a height.
  • Adds five regression tests covering buried points, terrain boundaries, holes, and model liquids.
File Description
src/​tools/​height-check/​HeightCheck.cpp Reports liquid using the queried point’s height.
src/​tests/​TerrainModelTest.cpp Adds five liquid-selection regression tests.
src/​shared/​terrain/​Terrain.hpp Adds optional terrain height to liquid data.
src/​shared/​terrain/​FusedTerrain.cpp Attaches terrain height to ADT liquid samples.
src/​shared/​terrain/​Column.hpp Preserves terrain metadata and adds LiquidFor(z) filtering.
src/​game/​WorldHandlers/​GridMap.cpp Uses height-aware selection for gameplay liquid status.

Review effort: Balanced

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 13 complexity · 0 duplication

Metric Results
Complexity 13
Duplication 0

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@AppVeyorBot

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants